<script setup>
import { ref } from 'vue'
import request from '@/utils/request'
import { getGoodsDetailService } from '@/api/goods.js'
import { ElMessage } from "element-plus"
import {useRoute} from 'vue-router'
import { onMounted, reactive } from 'vue'

const route = useRoute()
const goods_id = route.query.goods_id


//const goodsData = ref([])

// const goodsParams = ref({
//   goods_id:12123,
// })

const goodsInfo = reactive({
  goods: {},
  args: [],
  promotionInfo: [],
})
const { goods_params_id } = route.query
onMounted(() => {
  // request.post('/login/ajax?case=csLoginByPassword', {     
  //   'dsdsd':111
  //     }).then(res => {
  //   console.log(res)
   
  // })

   request.post('/goods/detail', {     
          goods_id: goods_id,
      }).then(res => {
    console.log(res)
    goodsInfo.goods = res.data.goods
    goodsInfo.args = res.data.args
    goodsInfo.promotionInfo = res.data.promotionInfo
  })
})






const getGoodsData = async () => {
  request.post('/goods/detail', {     
          goods_id: goods_id,
      }).then(res => {
        if(res.code == 1){
          const goodsData = res.data.goods
          console.log(res);
          console.log(111111);
          console.log(goodsData);
          console.log(goodsData.name);
        }
        
      })



  //console.log(res)
  //goodsData.value = res.data.goods
}


 //const data = await getGoodsDetailService(122416)
//console.log(data)



</script>
<template>
    <div>
      <h1>商品详情页</h1>
      <div style="margin-top: 50px ;">
      <div v-if="goodsData">{{ goodsData.name }}</div>
      <el-button  @click="getGoodsData()">获取商品详情</el-button>
      <div style="margin-top: 50px ;"></div>
      <div>
        {{  goodsInfo.goods.name}}
      </div>
  </div>

    </div>
</template>
  
  <style>
  </style>
  